import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

//全局过滤器
Vue.filter('time',function(val){
  //将时间转换为对象
  //获取到年月日时分秒，然后根据需求拼杰字符串
  var date = new Date(val)
  var Y = date.getFullYear();
  var M = date.getMonth();
  var D = date.getDate();
  var h = date.getHours();
  var f = date.getMinutes()+'';
      f = f.padStart(2,0)
  var m = date.getSeconds()+'';
      m = m.padStart(2,0)
  return `${Y}/${M}/${D} ${h}:${f}:${m}`
  //padStart(目标位数,"填充的字符") 不够目标位数  用填充的字符来填充

})

//导入全局样式表
import "./assets/css/global.css";

//引入axios拦截器
import axios from "@/utils/request.js"
Vue.prototype.$axios = axios;

//按需引入elementui.js'
import './ElementUi/elementui.js'
import 'element-ui/lib/theme-chalk/index.css';

//导入并使用全局方法和变量
import Global from './Global';
Vue.use(Global);

//注册全局列表li组件
import MiList from './components/list.vue'
Vue.component('MiList',MiList)


// 注册全局注册组件
import RegisterModule from './components/RegisterModule.vue'
Vue.component('RegisterModule',RegisterModule)

// 注册全局登陆组件
import LoginModule from './components/LoginModul.vue'
Vue.component('LoginModule',LoginModule)

//全局路由导航守卫
// router.beforeEach((to,form,next) =>{
//   console.log(router);
  
//   if(to.path == '/' || to.path == '/particulars' ||  to.path == '/allShop'){     
//       next();
//   }else if( !(this.$store.state.userName) ){
//       alert("还没有登录，请先登录！");
//       next('/');
//   }else{
//       next();
//   }
// })


Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
